home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbasix.zip / Qbasix.doc < prev    next >
Text File  |  1994-05-12  |  31KB  |  871 lines

  1.  
  2.          ┌───────────────────────────────────────┐
  3.          │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ QBASIX 2 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  4.          ├───────────────────────────────────────┤
  5.          │          QBASIc eXtender         │
  6.          │         version 2         │
  7.          │    an external library for QBasic     │
  8.          ├───────────────────────────────────────┤
  9.          │ Description of routines and functions │
  10.          └───────────────────────────────────────┘
  11.  
  12.  
  13.     Attr
  14.     ----
  15.     Function: Replacement for COLOR, especially handy when using
  16.           bright background colors.
  17.     Group:      Video attributes
  18.     Syntax:      DECLARE SUB Attr (Fore%, Back%)
  19.  
  20.     Attr does the same thing as COLOR: setting the colors for the
  21.     text and its background. However, the blink bit is not being set
  22.     by increasing the number of the text (foreground) color with 16,
  23.     but by increasing the number of the background color with 8.
  24.     This way of stating the color numbers is more convenient when
  25.     applying bright background colors. In that case you can use the
  26.     same set of color numbers for the foreground as well as for the
  27.     background color.
  28.  
  29.     When once you established a color combination by a call to Attr,
  30.     calling GetAttr informs you which color combination that is.
  31.  
  32.     The input parameters are:
  33.     Fore%    : the number of the text or foreground color
  34.     Back%    : the number of the background color
  35.  
  36.     If you want to change only one of both colors, you must give the
  37.     other the value -1 (you can not simply skip it, as with COLOR).
  38.     If you give Back% a value of 8 or higher the background takes
  39.     the color with the number given by Back less 8 and the text is
  40.     going to blink. However, if you did set the blink bit, that is
  41.     the highest bit of the background color number, to obtain bright
  42.     background colors you simply get a bright background color. To
  43.     set the blinkbit you can use the ToggleBlinkBit routine, also
  44.     included in this library.
  45.  
  46.  
  47.     BlinkStatus%
  48.     ------------
  49.     Function: Looks if blinking text is enabled or disabled
  50.     Group:      Video attributes
  51.     Syntax:      DECLARE FUNCTION BlinkStatus% ()
  52.     Requires: Loading of QBASIX.EXE
  53.  
  54.     This function returns -1 if setting the blink bit results in a
  55.     blinking text, and it returns 0 if it brightens the background.
  56.     When using this function it is convenient to define the
  57.     constants BRIGHT = 0 and BLINKING = -1. Obvious comparisons as
  58.  
  59.     IF BlinkStatus = BRIGHT THEN
  60.  
  61.     are possible then.
  62.     For more information read the comment with routine
  63.     ToggleBlinkbit.
  64.  
  65.  
  66.     Cmd$
  67.     ----
  68.     Function: Passes a command line, set by means of the switch /cmd
  69.           (as with QB) when calling QBASIC, to the program.
  70.     Group:      Command line
  71.     Syntax:      DECLARE FUNCTION Cmd$ ()
  72.  
  73.     If QBASIX is loaded you can start QBASIC with command line
  74.     parameters for the program to execute. The way you do that is
  75.     the same as with QuickBasic, the big brother of QBASIC, by
  76.     concluding the starting command with the parameter /cmd,
  77.     followed by the command line parameters you wish to provide. An
  78.     example:
  79.  
  80.     QBASIC /RUN program /CMD parameters for the program
  81.  
  82.     Nota bene: this does not work if QBASIX is not loaded. In that
  83.     case QBASIC considers /cmd and everything behind it a mistake
  84.     and stops with a summary of the syntax of the QBASIC command.
  85.  
  86.     With the Cmd$ function you can find out which parameters are
  87.     given at the command line, just as with COMMAND$ in QuickBasic.
  88.     In contrast to what COMMAND$ does Cmd$ preserves the case of
  89.     letters.
  90.  
  91.     A command line may not be longer than 80 characters. When you
  92.     provide a command line longer than that it will be truncated
  93.     down to a length of 80.
  94.  
  95.  
  96.     Exch%
  97.     -----
  98.     Function: Exchanges high and low byte of integer
  99.     Group:      Processing integers
  100.     Syntax:      DECLARE FUNCTION Exch% (SomeInt%)
  101.  
  102.     SomeInt% is the integer variable, the high and low bytes of
  103.     which have to be exchanged. The result is the value of the
  104.     function.
  105.     Example: suppose that the integer is &H5A21 (23073 decimal),
  106.     then the result is &H215A (8538 decimal).
  107.  
  108.  
  109.     FillWindow
  110.     ----------
  111.     Function: Colors foreground and/or background of a rectangular
  112.           text screen area and/or fills it with a character
  113.     Group:      Screen
  114.     Syntax:      DECLARE SUB FillWindow (Top%, Left%, Bottom%, Right%, _
  115.           Ascii%, Fore%, Back%)
  116.     Requires: Loading of QBASIX.EXE
  117.  
  118.     The meaning of the variables is as follows:
  119.     - Top% and Left% are the coordinates of the top left corner of
  120.       the screen window to fill.
  121.     - Bottom% and Right% are the coordinates of the bottom right
  122.       corner of the screen window to fill.
  123.     - Ascii% is the ASCII code of the character to place,
  124.     - Fore%     is the color code of the desired text color,
  125.     - Back%     is the color code of the desired background color
  126.  
  127.     The routine does not check the validity of the given
  128.     coordinates. They must be at least 1 and at most the number of
  129.     screen rows or columns of the active video mode. Moreover the
  130.     coordinates of the bottom right corner must be greater than or
  131.     equal to the corresponding coordinate of the top left corner.
  132.  
  133.     The existing state as to an attribute - character, text color or
  134.     background color - does not change if instead of a (positive)
  135.     attribute code a negative number is given. Suppose that only the
  136.     text color of the window (5, 10, 15, 40) must be changed in red
  137.     (code 4), then FillWindow must be called as:
  138.  
  139.       CALL FillWindow (5, 10, 15, 40, -1, 4, -1)
  140.  
  141.  
  142.     GetActiveColor
  143.     --------------
  144.     Function: Returns the screen color active in DOS
  145.     Group:      Video information
  146.     Syntax:      DECLARE SUB GetActiveColor%
  147.     Requires: Loading of QBASIX.EXE
  148.  
  149.     GetActiveColor returns the screen color active in DOS, as can
  150.     be set by means of ANSI commands. The function does not require
  151.     parameters.
  152.  
  153.     The lowest four bits of the returned value constitute the code
  154.     of the text color. It can be in the range from 0 through 15.
  155.     The next three bits represent the background color. Normally
  156.     this code can take the values 0 through 7. The highest bit is
  157.     the blink bit. Its meaning depends on a setting in the BIOS.
  158.     Normally the blinkbit lets the text blink. However, its meaning
  159.     can be set so that it makes the background bright. To reset the
  160.     meaning of the blinkbit you can use the ToggleBlinkBit routine,
  161.     also included in this library. Which meaning is operative at a
  162.     certain moment can be examined with the BlinkStatus% function.
  163.  
  164.     You get the separate colors in the following way
  165.  
  166.     ColorCode% = GetActiveColor%
  167.     TextColor% = (ColorCode% AND 15)
  168.     Background% = ColorCode% \ 16
  169.  
  170.     In this form you can use them with QBASIX' routine Attr. If you
  171.     want to use them with COLOR, you have to calculate them as
  172.     follows:
  173.  
  174.     ColorCode% = GetActiveColor%
  175.     TextColor% = (ColorCode% AND 15) + 16 * (ColorCode% \ 128)
  176.     Background% = ((ColorCode% \ 16) AND 7)
  177.  
  178.  
  179.     GetAttr
  180.     -------
  181.     Function: Returns the colors set with the previous call of Attr
  182.     Group:      Video attributes
  183.     Syntax:      DECLARE SUB GetAttr (Fore%, Back%)
  184.  
  185.     GetAttr returns the numbers of the colors you previously set
  186.     with Attr.
  187.  
  188.     The output parameters are:
  189.     Fore%    : the number of the text or foreground color
  190.     Back%    : the number of the background color
  191.  
  192.     For more information continue reading with the description of
  193.     Attr.
  194.  
  195.  
  196.     GetCursorLoc
  197.     ------------
  198.     Function: Gets the cursor location by way of the BIOS
  199.     Group:      Video attributes
  200.     Syntax:      DECLARE SUB GetCursorLoc (Row%, Column%)
  201.     Requires: Loading of QBASIX.EXE
  202.  
  203.     and
  204.  
  205.     SetCursorLoc
  206.     ------------
  207.     Function: Sets the cursor location by way of the BIOS
  208.     Group:      Video attributes
  209.     Syntax:      DECLARE SUB SetCursorLoc (Row%, Column%)
  210.     Requires: Loading of QBASIX.EXE
  211.  
  212.     The parameters Row% and Column% are the row and column
  213.     coordinate of the cursor position, respectively.
  214.  
  215.     Both only work for page 0, the default page. The top left corner
  216.     of the screen is (1,1), just as in BASIC. BASIC commands sending
  217.     output to the screen do not react to the SetCursorLoc command.
  218.     Therefore use LOCATE instead. GetCursorLoc gives the same result
  219.     as BASICs CSRLIN and POS.
  220.  
  221.     The two routines are useful if you send your output to the
  222.     screen by way of DOS. The way you do that is by opening the
  223.     screen as a DOS device with the name "CONS:", as recognized by
  224.     BASIC, or with the name "CON", which is recognized by DOS. It
  225.     goes as follows:
  226.  
  227.     OPEN "CONS:" FOR OUTPUT AS #1
  228.     ...
  229.     PRINT #1, ...
  230.     ...
  231.     CLOSE #1
  232.  
  233.     Output to the screen obeys the LOCATE command, it is true, but
  234.     BASIC does not keep the position of the cursor. As a result
  235.     CSRLIN and POS do not return the correct value. Instead of them
  236.     GetCursorLoc has to be used.
  237.  
  238.     Now you will wonder why not always use the ordinary PRINT
  239.     statement to send output to the screen. After all that is
  240.     faster. Well, suppose you want to redirect the output to a file
  241.     in order to view it at your ease later on. That is possible, but
  242.     only if DOS acts as an intermediary. PRINT does not use DOS,
  243.     however!
  244.  
  245.     An other advantage of output by way of DOS can be that DOS
  246.     colors will be used automatically.
  247.  
  248.  
  249.     GetVideoInfo
  250.     ------------
  251.     Function: Returns information about the video configuration
  252.     Group:      Video information
  253.     Syntax:      DECLARE SUB GetVideoInfo (Video AS VideoType)
  254.     Requires: Loading of QBASIX.EXE
  255.  
  256.     GetVideoInfo places information about the video configuration in
  257.     a record of the type VideoType. This type has the following
  258.     structure:
  259.  
  260.     TYPE VideoType
  261.       Mode    AS INTEGER  : videomode
  262.       Rows    AS INTEGER  : text: number of screen rows
  263.       Cols    AS INTEGER  : text: number of screen columns
  264.       Page    AS INTEGER  : text: number of active screen page
  265.       Offs    AS INTEGER  : text: offset of active page in video memory
  266.       Segment AS INTEGER  : text: segment of the same
  267.       CRT     AS INTEGER  : adapter: MDA = 1, CGA = 2, EGA = 3,
  268.                 MCGA = 4, VGA = 5, HERC = 11,
  269.                 OTHER = 0
  270.       Colour  AS INTEGER  : -1 (TRUE) if color screen,
  271.                 0 (FALSE) if monochrome screen
  272.       Port    AS INTEGER  : port of video controller
  273.     END TYPE
  274.  
  275.     The video mode is the mode as reported by the BIOS. This number
  276.     is not the same as the screen number according to BASIC!.
  277.     Consult an appropriate book for the codes given by the BIOS, for
  278.     instance "Programmers quick reference guide IBM ROM BIOS", by
  279.     Ray Duncan, published by Microsoft Press. With IBM video
  280.     adapters the text modes are: 0 through 3 (color) and 7
  281.     (monochrome). The other modes are graphic modes. The modi
  282.     numbered 20 and higher are not standard. For the sake of
  283.     security their memory segment is given as &HA000. Often that is
  284.     the correct value, but &HB000 and especially &HB800 do appear
  285.     also. Consult the manual of your video adapter for that.
  286.  
  287.  
  288.     For the sake of a better recognizibility of the adapter code the
  289.     following constants are defined as a supplement to VideoType:
  290.  
  291.     CONST OTHER = 0, MDA = 1, CGA = 2, EGA = 3, MCGA = 4, VGA = 5
  292.  
  293.  
  294.     GetVideoMode%
  295.     -------------
  296.     Function: Returns the active video mode
  297.     Group:      Video information
  298.     Syntax:      DECLARE FUNCTION GetVideoMode% ()
  299.     Requires: Loading of QBASIX.EXE
  300.  
  301.     The goal of this function is to be able to examine quickly which
  302.     video mode is active. The ballast of a complete Videotype
  303.     variable is avoided. Getvideomode therefore is much faster than
  304.     GetVideoInfo.
  305.  
  306.  
  307.     Hi%
  308.     ---
  309.     Function: Returns high byte of integer
  310.     Group:      Processing integers
  311.     Syntax:      DECLARE FUNCTION Hi% (SomeInt%)
  312.  
  313.     SomeInt% is the integer variable, the high byte of which is
  314.     requested. The result is the value of the function.
  315.     Example: suppose that the integer is &H5A21 (23073 decimal),
  316.     then the result is &H5A (90 decimal).
  317.  
  318.  
  319.     InterruptX
  320.     ----------
  321.     Function: Executes interrupt
  322.     Group:      System
  323.     Syntax:      DECLARE SUB InterruptX (Number%, InReg AS RegTypeX, _
  324.           OutReg AS RegTypeX)
  325.     Requires: Loading of QBASIX.EXE
  326.  
  327.     By means of this routine software interrupts can be executed in
  328.     a BASIC program. It replaces the routine of the same name
  329.     supplied by Microsoft. Its functionality is the same.
  330.  
  331.     The number of the interrupt service routine to execute has to be
  332.     be specified as the first parameter of InterruptX. The input
  333.     values of the registers should be placed in InReg, the output
  334.     values go in OutReg. Both variables are of the type RegtypeX.
  335.  
  336.     The interrupt number can not be lees than 0 or greater than 255.
  337.     If a number is given outside these limits, the number will be
  338.     set to -1 (0FFFFh) to indicate an error. This is taken from the
  339.     original QuickBasic routine.
  340.  
  341.     By means of InterruptX the registers AX, BX, CX, DX, BP, SI, DI,
  342.     DS and ES can be set and, after calling the ISR, be read. If one
  343.     does not want to change the registers DS, ES and/or BP, they
  344.     should be provided to the routine with the value -1 (0FFFFh).
  345.     In that case the routine will return with the actual value of
  346.     these registers immediately after executing the interrupt. In
  347.     case a DOS interrupt &H21 is being executed with this routine
  348.     register BP is not used, notwithstanding the value of Inreg.BP.
  349.  
  350.     If a critical error appears when using this routine for DOS
  351.     functions the critical error handler of BASIC comes in action.
  352.     As a consequence the program, when returned from the interrupt
  353.     routine, will come under control of an error handling routine
  354.     activated by ON ERROR GOTO, or will stop with an error message
  355.     if such an error handler is not available.
  356.  
  357.     A not critical error, such as for instance file not found, does
  358.     not trigger a BASIC error and therefore has to be catched in
  359.     another way. If an error has occurred the first bit - that is
  360.     the carry bit - of the flags register is on (that is equal to
  361.     1). In that case the error handling routine can be activated.
  362.     Now however it must not react to BASIC error numbers, but to DOS
  363.     error numbers.
  364.  
  365.  
  366.     IntMax%
  367.     -------
  368.     Function: Returns the maximum of 2 integers
  369.     Group:      Processing integers
  370.     Syntax:      DECLARE FUNCTION IntMax% (Int1%, Int2%)
  371.  
  372.     Int1% and Int2% are the integers the maximum of which has to be
  373.     determined. The result is the value of the function.
  374.  
  375.  
  376.     IntMin%
  377.     -------
  378.     Function: Returns the minimum of 2 integers
  379.     Group:      Processing integers
  380.     Syntax:      DECLARE FUNCTION IntMin% (Int1%, Int2%)
  381.  
  382.     Int1% and Int2% are the integers the minimum of which has to be
  383.     determined. The result is the value of the function.
  384.  
  385.  
  386.     Lo%
  387.     ---
  388.     Function: Returns low byte of integer
  389.     Group:      Processing integers
  390.     Syntax:      DECLARE FUNCTION Lo% (SomeInt%)
  391.  
  392.     SomeInt% is the integer variable, the low byte of which is
  393.     requested. The result is the value of the function.
  394.     Example: suppose that the integer is &H5A21 (23073 decimal),
  395.     then the result is &H21 (33 decimal).
  396.  
  397.  
  398.     LptReady%
  399.     ---------
  400.     Function: Determines if printer is ready and passes printer
  401.           status
  402.     Group:      Printer
  403.     Syntax:      DECLARE FUNCTION LptReady% (Lpt%, Status%)
  404.     Requires: Loading of QBASIX.EXE
  405.  
  406.     LptReady% returns -1 (TRUE) if the printer is ready and 0
  407.     (FALSE) otherwise.
  408.  
  409.     Input parameters:
  410.     Lpt%    : number of the printer to be examined (1, 2 or 3).
  411.  
  412.     Output parameter:
  413.     Status% : extended specification of the printer status.
  414.  
  415.     In the Status% variable the printer status according to the BIOS
  416.     is characterized by the sum of one or more of the following
  417.     values:
  418.  
  419.       1 - the printer does not react within a fixed time;
  420.       8 - I/O error;
  421.      16 - the printer is selected;
  422.      32 - the printer is out of paper;
  423.      64 - printer acknowledgement;
  424.     128 - printer not busy;
  425.     256 - printer not connected;
  426.     512 - invalid printer number.
  427.  
  428.     The values 256 and 512 are values attributed not by the BIOS but
  429.     by the function itself. The printer is ready if it is selected
  430.     and not one of the errors 1, 8 or 32 has occurred. You can test
  431.     for each of the conditions by means of the operator AND, for
  432.     instance:
  433.  
  434.     IF Status% AND 32 THEN
  435.       PRINT "The printer is out of paper"
  436.     END IF
  437.  
  438.  
  439.     MemCopy
  440.     -------
  441.     Function: Copies a number of bytes from one memory location to
  442.           another
  443.     Group:      Memory
  444.     Syntax:      DECLARE SUB MemCopy (Bytes&, SourceSeg%, _
  445.           SourceOffs%, TargetSeg%, TargetOffs%)
  446.     Requires: Loading of QBASIX.EXE
  447.  
  448.     This routine copies a number of bytes from one memory location
  449.     to another.
  450.  
  451.     The input parameters are, first, the number of bytes to copy:
  452.     Bytes&        : the number of bytes to copy,
  453.  
  454.     and next the segmented addresses of source and target:
  455.  
  456.     SourceSeg%    : the segment of the source address,
  457.     SourceOffs%    : the offset of the source address,
  458.     TargetSeg%    : the segment of the target address,
  459.     TargetOffs%    : the offset of the target address.
  460.  
  461.     The maximum number of bytes to copy in one go is 64 Kb.
  462.  
  463.     You can copy bytes from every part of memory to every other
  464.     part. The target may partially overlap the original location.
  465.     Be cautious in using this routine. It is easy to overwrite
  466.     information essential for the operation of the program, or even
  467.     the PC. The least bad thing possible to happen then is that the
  468.     PC stops functioning, after which you have to start it anew.
  469.     However, in special cases it can occur that for instance
  470.     information on the hard disc is overwritten.
  471.  
  472.     Copying from one BASIC variable to another is easy and
  473.     comparatively dangerless. For that you have to use the pointer
  474.     functions VARSEG and VARPTR, unless it concerns variable length
  475.     strings. In that case you have to use the pointer function SADD
  476.     (that is StringADDress). Note the number of bytes to copy: if
  477.     the number of bytes is greater than fits in the target variable
  478.     information following that variable is overwritten. That can
  479.     have nasty consequences.
  480.  
  481.     Maybe the question will now arise: why use MemCopy for copying
  482.     of variables?  Can't one simply use the BASIC assignment command
  483.     for that, for instance A = B?  Well, that will do for simple
  484.     variables, but not for arrays. For in that case a loop over all
  485.     elements should have to be made. With MemCopy you can do it in
  486.     one single command. Note that this can't be done with string
  487.     arrays. If you apply MemCopy to string arrays you make a mess of
  488.     your computer's memory and without doubt your PC will throw it
  489.     up.
  490.  
  491.     An other possible application of MemCopy is copying of
  492.     information to and from the video memory.
  493.  
  494.  
  495.     MemScan&
  496.     --------
  497.     Function: Scans a memory block of at most 64Kb for a string
  498.     Group:      Memory
  499.     Syntax:      DECLARE FUNCTION MemScan& (Bytes&, SourceSeg%, _
  500.           SourceOffs%, Search$)
  501.     Requires: Loading of QBASIX.EXE
  502.  
  503.     This function scans an arbitrary memory block, beginning at a
  504.     specified address and having a certain length, for the first
  505.     ocurrence of a string, that is the search string. The maximum
  506.     length of the memory block to scan is 64 Kb (65535 bytes). If
  507.     the string is found the function returns its offset relative to
  508.     the specified segment. Otherwise the function returns -1.
  509.  
  510.     The input parameters are, first, the number of bytes to scan:
  511.     Bytes&        : the number of bytes to scan.
  512.  
  513.     and next the segmented address of the start of the memory block
  514.     to scan:
  515.  
  516.     SourceSeg%    : the segment of the address of the memory block
  517.               to scan,
  518.     SourceOffs%    : the offset of the same.
  519.  
  520.     You can use MemScan to scan the contents of a variable for a
  521.     certain string. In that case you have to use BASIC's pointer
  522.     functions to provide the variable's address: VARSEG for the
  523.     segment, SADD for the offset of variable length strings, and
  524.     VARPTR for the offset of all other variables. As the number of
  525.     bytes to scan you pass the length of the variable.
  526.  
  527.     MemScan lends itself very well for scanning fixed length
  528.     strings. Using MemScan instead of the BASIC function INSTR
  529.     has the advantage that no temporary variable length string is
  530.     made and erased afterwards. That makes a difference in space and
  531.     time.
  532.  
  533.     For scanning a string of variable length you can as well use
  534.     INSTR.
  535.  
  536.  
  537.     MSDOS
  538.     -----
  539.     Function: Executes DOS interrupt
  540.     Group:      System
  541.     Syntax:      DECLARE SUB MSDOS (InReg AS RegTypeX, _
  542.           OutReg AS RegTypeX)
  543.     Requires: Loading of QBASIX.EXE
  544.  
  545.     MSDOS is a general interface for the functions DOS provides by
  546.     way of its interrupt service routine &H21. It is no more than a
  547.     shortened call of the standard INTERRUPTX routine. Errors can be
  548.     trapped with BASIC's ON ERROR only if they are critical, that
  549.     is to say, errors originating in a device, for instance a drive
  550.     or a printer. Others errors can be detected only by consulting
  551.     the flags register.
  552.  
  553.     Input parameter:
  554.     InReg AS RegTypeX: the register values to provide,
  555.  
  556.     Output parameter:
  557.     OutReg AS RegTypeX: the register values returned.
  558.  
  559.     The BP register is defined in RegTypeX to be sure, but cannot be
  560.     used by routine MSDOS.
  561.  
  562.     See for further reading the discussion under INTERRUPTX.
  563.  
  564.  
  565.     PeekString$
  566.     -----------
  567.     Function: Reads a string of specified length from specified
  568.           address
  569.     Group:      Memory
  570.     Syntax:      DECLARE FUNCTION PeekString$(Segment%, Offset%, Length%)
  571.  
  572.     The function returns the string of length Length% beginning at
  573.     the segmented address passed as a parameter.
  574.  
  575.     Segment%    : segment of the string address
  576.     Offset%        : offset of the string address
  577.     Length%        : the length of the string
  578.  
  579.  
  580.     PeekWord%
  581.     ---------
  582.     Function: Reads a word from the specified address
  583.     Group:      Memory
  584.     Syntax:      DECLARE FUNCTION PeekWord% (Segment%, Offset%)
  585.  
  586.     The function returns the integer value of the word (two bytes
  587.     that are) at the segmented memory address passed as a parameter.
  588.  
  589.     Segment%    : segment of the word address
  590.     Offset%        : offset of the word address
  591.  
  592.     PeekWord does about the same as PEEK, but returns a word (whole
  593.     integer) instead of a byte (half an integer). Moreover the
  594.     segment can be passed as a parameter without the need to declare
  595.     it with DEF SEG.
  596.  
  597.     The function is borrowed from a book of Ziff-Davis Press
  598.     (1991).
  599.  
  600.  
  601.     PokeWord
  602.     --------
  603.     Function: Writes a word to the specified address
  604.     Group:      Memory
  605.     Syntax:      DECLARE SUB PokeWord (Segment%, Offset%, Value%)
  606.  
  607.     This routine places the integer value (two bytes) given as
  608.     Value% at the memory address passed as the first parameter.
  609.  
  610.     Segment%    : segment of the address
  611.     Offset%        : offset of the address
  612.     Value%        : the value to place in memory
  613.  
  614.     PokeWord does about the same as POKE, but places a word (whole
  615.     integer) instead of a byte (half an integer) at the indicated
  616.     memory location. Moreover the segment can be passed as a
  617.     parameter without the need to declare it with DEF SEG.
  618.  
  619.     The procedure is borrowed from a book of Ziff-Davis Press
  620.     (1991).
  621.  
  622.  
  623.     RestoreScreen
  624.     -------------
  625.     Function: Restores rectangular text screen area (window) from
  626.           buffer array
  627.     Group:      Screen
  628.     Syntax:      DECLARE SUB RestoreScreen (ScreenBuffer%())
  629.     Requires: Loading of QBASIX.EXE
  630.  
  631.     and
  632.  
  633.     SavePartScreen
  634.     --------------
  635.     Function: Saves screen window with cursor location and color
  636.           setting in buffer array
  637.     Group:      Screen
  638.     Syntax:      DECLARE SUB SavePartScreen (Top%, Left%, Bottom%, _
  639.           Right%, ScreenBuffer%())
  640.     Requires: Loading of QBASIX.EXE
  641.  
  642.     and
  643.  
  644.     SaveScreen
  645.     ----------
  646.     Function: Saves full screen with cursor location and color
  647.           setting in buffer array, taking into account the
  648.           active video mode
  649.     Group:      Screen
  650.     Syntax:      DECLARE SUB SaveScreen (ScreenBuffer%())
  651.     Requires: Loading of QBASIX.EXE
  652.  
  653.     SaveScreen lets you store the screen contents in a buffer in
  654.     order to be able to restore the screen to its old state later
  655.     on. Prior to calling SaveScreen you have to declare a dynamic
  656.     array ScreenBuffer, in which the routine can store the screen
  657.     contents. You don't need to give the right number of elements
  658.     yourself. If the number of elements is too small SaveScreen
  659.     takes care of making the buffer large enough. So you can confine
  660.     yourself to, for instance:
  661.  
  662.     REDIM ScreenBuffer%(0)
  663.  
  664.     Note that the command REDIM is used in stead of DIM. Using REDIM
  665.     will make the array dynamic, so its size can be changed later
  666.     on. There are other ways for making an array dynamic, but this
  667.     is the easiest.
  668.  
  669.     SaveScreen supports any number of rows or columns, but only
  670.     one screen page. By default this is screen page number 0.
  671.  
  672.     Using SaveScreen is of course somewhat wasteful in its claim on
  673.     memory if only a part of the screen really has to be saved. The
  674.     routine SavePartScreen is introduced to do something about that.
  675.     With this routine it is possible to store a part of the screen -
  676.     a window - in a buffer. SavePartScreen too will take care of
  677.     making the buffer large enough.
  678.  
  679.     (Top%, Left%) are the co-ordinates of the top left corner of the
  680.     window, and (Bottom%, Right%) those of the bottom right corner.
  681.     Top% and Bottom% relate to the row co-ordinate (y), where as
  682.     Left% and Right% refer to the column co-ordinate (x). It may be
  683.     clear that now you have to check yourself if the co-ordinates
  684.     fit the size of the screen.
  685.  
  686.     The window contents are restored with the same routine as with
  687.     which a complete screen is restored, that is, with
  688.     RestoreScreen.
  689.  
  690.     You can save more windows at the same time by defining more
  691.     screen buffers and save every window in its own buffer.
  692.  
  693.  
  694.     SetCmd
  695.     ------
  696.     Function: Changes the command line meant for the basic program
  697.           from inside QBASIC
  698.     Group:      Command line
  699.     Syntax:      DECLARE SUB SetCmd (CmdStr$)
  700.  
  701.     If QBASIX is loaded you can start QBASIC with a command line for
  702.     your program to run, preceded by the switch /cmd. By calling the
  703.     function Cmd$ in the program you can find out which command line
  704.     is given, just as you can do in QuickBasic by calling COMMAND$.
  705.  
  706.     If you are testing your program it can be convenient to be able
  707.     to change the command line from inside QBASIC. That is the
  708.     purpose of the SetCmd procedure. When you insert it in your
  709.     program you can use it from the immediate window. Press F6 to go
  710.     to that window and enter there
  711.  
  712.     setcmd "the new command line"
  713.  
  714.     followed by Enter. The text between quotes is to be replaced by
  715.     the command line you wish to provide. The lengthe of the command
  716.     line may not exceed 80 characters. When you enter a line longer
  717.     than that it will be truncated to the maximum length.
  718.  
  719.     When your program runs well one day, SetCmd has done its service
  720.     and you can delete it from the program.
  721.  
  722.  
  723.     SetCursorLoc
  724.     ------------
  725.     Function: Sets the cursor location by way of the BIOS
  726.     Group:      Video attributes
  727.     Syntax:      DECLARE SUB SetCursorLoc (Row%, Column%)
  728.     Requires: Loading of QBASIX.EXE
  729.  
  730.     See for description under GetCursorLoc.
  731.  
  732.  
  733.     SetError
  734.     --------
  735.     Function: Sets termination code (error level) of program
  736.     Group:      Termination code
  737.     Syntax:      DECLARE SUB SetError (ErrorLevel%)
  738.     Requires: Loading of QBASIX.EXE
  739.  
  740.     With SetError the termination code or error level of the running
  741.     (basic) program can be set.
  742.  
  743.     Input parameter:
  744.     ErrorLevel% : the termination code to set (0 - 255).
  745.  
  746.     If the program is started in a batch file, its error level at
  747.     termination can be obtained afterwards by means of IF
  748.     ERRORLEVEL. Depending on its value the execution of the batch
  749.     file can then be continued in a proper way.
  750.  
  751.     Nota bene: if you set a termination code once it remains in
  752.     force as long as you stay inside QBASIC. It makes no difference
  753.     if you terminate the program and subsequently run another
  754.     program, as long as you don't leave QBASIC.
  755.  
  756.  
  757.     SetHi
  758.     -----
  759.     Function: Gives high byte of integer another value
  760.     Group:      Processing integers
  761.     Syntax:      DECLARE SUB SetHi (SomeInt%, HiByte%)
  762.  
  763.     SomeInt% is the integer variable to the high byte of which the
  764.     value of HiByte% must be attached. The existing value of
  765.     SometInt% is overwritten.
  766.     Example: suppose that SomeInt% has the value &H5A21 (23073
  767.     decimal), and that we choose &HD4 (212 decimal) as the value of
  768.     HiByte%, then SomeInt% will get the new value &HD421 (54305
  769.     decimal).
  770.  
  771.  
  772.     SetLo
  773.     -----
  774.     Function: Gives low byte of integer another value
  775.     Group:      Processing integers
  776.     Syntax:      DECLARE SUB SetLo (SomeInt%, LoByte%)
  777.  
  778.     SomeInt% is the integer variable to the low byte of which the
  779.     value of LoByte% must be attached. The existing value of
  780.     SometInt% is overwritten.
  781.     Example: suppose that SomeInt% has the value &H5A21 (23073
  782.     decimal), and that we choose &H8E (142 decimal) as the value of
  783.     LoByte%, then SomeInt% will get the new value &H5A8E (23182
  784.     decimal).
  785.  
  786.  
  787.     SetWord%
  788.     --------
  789.     Function: Forms integer from high byte and low byte
  790.     Group:      Processing integers
  791.     Syntax:      DECLARE FUNCTION SetWord% (HiByte%, LoByte%)
  792.  
  793.     HiByte% and LoByte% contain the values of the high byte and the
  794.     low byte respectively of the integer value to form. The
  795.     resulting value is attached to the function SetWord%.
  796.     Example: suppose we choose &H77 (119 decimal) as the high byte's
  797.     value, and &H0C (12 decimal) as the low byte's value, then the
  798.     result is &H770C (30476 decimaal).
  799.  
  800.  
  801.     Shift
  802.     -----
  803.     Function: Shifts bits of integer a number of places to the left
  804.           or the right
  805.     Group:      Processing integers
  806.     Syntax:      DECLARE SUB Shift (Direction%, SomeInt%, Bits%)
  807.     Requires: Loading of QBASIX.EXE
  808.  
  809.     With this procedure you can shift the bits of an integer a
  810.     number of places to the left or to the right.
  811.  
  812.     Input parameters:
  813.     Direction%    : indicates the direction in which to shift:
  814.               0 for left, and 1 for right.
  815.     SomeInt%    : integer the bits of which are to be shifted.
  816.     Bits%        : number of positions to shift.
  817.  
  818.     When shifting to left the highest Bits% bits will be lost, when
  819.     shifting to right the same will be the case for the lowest Bits%
  820.     bits. When shifting to left the result is equal to
  821.  
  822.     SomeInt% * 2 ^ Bits%,
  823.  
  824.     and when shifting to right it is equal to
  825.  
  826.     SomeInt% \ 2 ^ Bits%.
  827.  
  828.     This procedure is much faster however.
  829.  
  830.     It is convenient to define the constants LEFT = 0 and RIGHT = 1
  831.     when using this procedure. Clear commands as
  832.  
  833.     Shift LEFT, number%, 2
  834.  
  835.     are possible then.
  836.  
  837.  
  838.     ToggleBlinkBit
  839.     --------------
  840.     Function: Enables or disables blinking text
  841.     Group:      Video attributes
  842.     Syntax:      DECLARE SUB ToggleBlinkBit (Toggle%)
  843.     Requires: Loading of QBASIX.EXE
  844.  
  845.     The highest bit of the color byte of a screen position - the
  846.     color attribute - can have two different meanings:
  847.     1. The text blinks.
  848.     2. The background is bright.
  849.     It derives its name "blink bit" from the first meaning. By
  850.     default the first meaning is operative.
  851.  
  852.     With the help of the ToggleBlinkBit procedure it is possible to
  853.     choose which meaning the blink bit will have. If an odd value is
  854.     chosen for the parameter Toggle% the blink bit will let the text
  855.     blink, otherwise it will make the background bright. In that
  856.     last case you have the choice of eight extra, bright colors for
  857.     the background, but blinking text is not possible anymore. The
  858.     blink bit's meaning you choose is effective for the whole screen
  859.     immediately, not only from the current position on the screen.
  860.  
  861.     The blink bit is defined for text modes only. The routine also
  862.     works for the older MDA and CGA screens.
  863.  
  864.     It is convenient to define the constants BRIGHT = 0 and BLINKING
  865.     = -1 when using this function. Clear commands as
  866.  
  867.     ToggleBlinkBit BRIGHT
  868.  
  869.     are possible then.
  870.  
  871.